<template>
    <div style=" position: relative;"><el-card>
            <template #header>
                <!-- 搜索 -->
                <div>
                    <el-input style="width: 360px;" v-model="find_data.find" placeholder="请输入班次/车次号" clearable
                        prefix-icon="Search" />
                    <el-button style="margin-left: 20px;height:30px" @click="search_btn" type="primary"
                        icon="Search">搜索</el-button>
                </div>
                <!-- 功能按钮 -->
                <div style="margin-top:10px;">
                    <el-button @click="add_btn" type="primary" icon="SuccessFilled">添加</el-button>
                    <el-button @click="up_btn" type="warning" icon="WarnTriangleFilled">修改</el-button>
                    <el-button @click="del_btn" type="danger" icon="CircleCloseFilled">删除</el-button>
                </div>
            </template>
            <div>
                <el-table border @selection-change="selection_change_btn" height="67vh" ref="multipleTableRef"
                    :data="list_data" style="width: 100%">
                    <el-table-column type="selection" width="35" />
                    <el-table-column label="编号" width="55" fixed type="index" />

                    <template v-for="item in table_data_list_new" :key="item.field">
                        <el-table-column v-if="item.off" :width="item.width" :prop="item.field" :label="item.label">
                            <template v-if="item.field == 'numInfo'" #="{ row, column, $index }">

                                <div v-if="row.numInfo.travelWay == 1 || row.numInfo.travelway == 1">
                                    <div v-for="it in row.numInfo.list" :key="it.no">
                                        <div>
                                            <b>起点：</b>
                                            {{ it.depCity }} {{ it.depPort + it.depTerminal }} | {{ it.depScheduled }}
                                        </div>
                                        <div>
                                            <b>终点：</b>
                                            {{ it.arrCity }} {{ it.arrPort + it.arrTerminal }} | {{ it.arrScheduled }}
                                        </div>
                                    </div>
                                </div>
                                <div v-if="row.numInfo.travelWay == 2 || row.numInfo.travelway == 2">

                                    <div>
                                        <b>{{ row.numInfo.trainno }} </b> |
                                        <b>{{ row.numInfo.startstation }}</b> 至 <b>{{ row.numInfo.endstation }}</b>
                                    </div>
                                    <span v-for="it in row.numInfo.list" :key="it.sequenceno">
                                        <span>[第{{ it.sequenceno }}站 <b>{{ it.station }}</b> | {{ it.arrivaltime }}~{{
                                            it.departuretime }} 停留{{ it.stoptime }}分钟] </span>
                                    </span>
                                </div>

                            </template>


                        </el-table-column>
                    </template>
                </el-table>
            </div>

            <div style="margin-top:20px">
                <el-pagination @current-change="current_change_btn" @size-change="size_change_btn"
                    v-model:current-page="find_data.page.pageNum" v-model:page-size="find_data.page.pageSize"
                    :page-sizes="[20, 50, 100, 200]" :background="true"
                    layout="prev, pager, next, jumper,->,sizes,total," :total="total" />
            </div>
        </el-card>
    </div>

    <!-- 弹窗 -->
    <div>
        <!-- 表格筛选 -->
        <div style="position: absolute;top:75px;z-index: 2;" :style="icon_off ? 'right:0px;' : 'right:110px;'">
            <el-icon @click="icon_btn" :size="20">
                <Setting />
            </el-icon>
            <div v-show="icon_off"
                style=" position: relative;top:-100px;right:140px;width: 130px;height:430px;background:#fff;overflow: hidden;">
                <div class="cols-set" style="background:#fff;width:90%;height:97%;margin:auto;margin-top:10px;">
                    <div>
                        <el-button-group style="display: flex; ">
                            <el-tooltip effect="dark" placement="bottom">
                                <template #content>注意：拖动下面的项，可以改变表格列的顺序，<br />记得点击保存才会永久生效哦！ </template>
                                <el-button style="width:10px" type="primary" icon="WarningFilled"></el-button>
                            </el-tooltip>
                            <el-button title="重置" type="primary" icon="Refresh" @click="resetTableSet"></el-button>
                            <el-button title="保存" type="primary" icon="Check" @click="saveTableSet"></el-button>
                        </el-button-group>
                        <div ref="sortableContainer" class="col-items" style="height:400px; overflow-y: auto; ">
                            <el-checkbox class="drag_it" @change="checkbox_btn" v-for="item in sortedItems"
                                :key="item.field" v-model="item.off" :label="item.label" border>
                            </el-checkbox>
                        </div>

                    </div>
                </div>
            </div>
        </div>
        <!-- 添加修改 -->
        <el-dialog style="margin-top:5vh" v-model="add_off" :title="title" width="800px" :close-on-click-modal='false'>
            <el-form :model="add_data" :label-width="'100px'">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="出行方式" prop="travelWay" :rules="[{ required: false, message: '出行方式不能为空' }]">
                            <el-select v-model="add_data.travelWay" placeholder="请选择出行方式" style="width: 100%;">
                                <el-option label="飞机" value="1"></el-option>
                                <el-option label="火车" value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>

                    <el-col :span="12">
                        <el-form-item :label="add_data.travelWay == 1 ? '班次号' : '车次号'" prop="flightTrainNum" :rules="[
                            { required: false, message: `${add_data.travelWay == 1 ? '班次号' : '车次号'}不能为空` },
                        ]">
                            <el-input v-model="add_data.flightTrainNum"
                                :placeholder="`请输入${add_data.travelWay == 1 ? '班次号' : '车次号'}`" maxlength="20" clearable
                                style="width: 100%;">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <template v-if="add_data.travelWay == 1">
                    <div v-for="item, index in add_data.flightInfo" :key="index">

                        <el-divider v-if="index != 0">
                            <el-button @click="and_del_btn(index)" type="danger" icon="star-filled">删除</el-button>
                        </el-divider>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="出发城市" prop="scity"
                                    :rules="[{ required: false, message: '出发城市不能为空' },]">
                                    <el-input v-model="item.scity" placeholder="请输入出发城市 eg：成都市" maxlength="20" clearable
                                        style="width: 100%;">
                                    </el-input>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="到达城市" prop="ecity" :rules="[
                                    { required: false, message: '到达城市不能为空' },]">
                                    <el-input v-model="item.ecity" placeholder="请输入到达城市 eg：上海市" maxlength="20" clearable
                                        style="width: 100%;">
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="出发站点" prop="splace" :rules="[
                                    { required: false, message: '出发站点不能为空' },
                                ]">
                                    <el-input v-model="item.splace" placeholder="请输入出发站点 eg：成都东站" maxlength="20"
                                        clearable style="width: 100%;">
                                    </el-input>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item v-if="terminal_off(item.splace)" label="出发航站楼" prop="sterminal"
                                    :rules="[{ required: false, message: '出发航站楼不能为空' }]">
                                    <el-select v-model="item.sterminal" placeholder="请选择出发航站楼" style="width: 100%;">
                                        <el-option label="T1" value="T1"></el-option>
                                        <el-option label="T2" value="T2"></el-option>
                                        <el-option label="T3" value="T3"></el-option>
                                        <el-option label="T4" value="T4"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item v-else label="出发航站楼" prop="sterminal"
                                    :rules="[{ required: false, message: '出发航站楼不能为空' }]">
                                    <el-select v-model="item.sterminal" placeholder="请选择出发航站楼" style="width: 100%;">
                                        <el-option label="T1" value="T1"></el-option>
                                        <el-option label="T2" value="T2"></el-option>
                                    </el-select>
                                </el-form-item>

                            </el-col>

                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="到达站点" prop="eplace" :rules="[
                                    { required: false, message: '到达站点不能为空' },
                                ]">
                                    <el-input v-model="item.eplace" placeholder="请输入到达站点 eg：成都西站" maxlength="20"
                                        clearable style="width: 100%;">
                                    </el-input>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item v-if="terminal_off(item.eplace)" label="到达航站楼" prop="eterminal"
                                    :rules="[{ required: false, message: '到达航站楼不能为空' }]">
                                    <el-select v-model="item.eterminal" placeholder="请选择到达航站楼" style="width: 100%;">
                                        <el-option label="T1" value="T1"></el-option>
                                        <el-option label="T2" value="T2"></el-option>
                                        <el-option label="T3" value="T3"></el-option>
                                        <el-option label="T4" value="T4"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item v-else label="到达航站楼" prop="eterminal"
                                    :rules="[{ required: false, message: '到达航站楼不能为空' }]">
                                    <el-select v-model="item.eterminal" placeholder="请选择到达航站楼" style="width: 100%;">
                                        <el-option label="T1" value="T1"></el-option>
                                        <el-option label="T2" value="T2"></el-option>

                                    </el-select>
                                </el-form-item>

                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="出发时间" prop="stime" :rules="[
                                    { required: false, message: '出发时间不能为空' },
                                ]">
                                    <el-time-picker format="HH:mm" value-format="HH:mm" v-model="item.stime"
                                        :picker-options="{
                                            selectableRange: '00:00:00 - 23:59:59'
                                        }" placeholder="选择出发时间" style="width: 100%;">
                                    </el-time-picker>
                                </el-form-item>
                            </el-col>

                            <el-col :span="12">
                                <el-form-item label="到达时间" prop="etime" :rules="[
                                    { required: false, message: '到达时间不能为空' },
                                ]">
                                    <el-time-picker format="HH:mm" value-format="HH:mm" v-model="item.etime"
                                        :picker-options="{
                                            selectableRange: '00:00:00 - 23:59:59'
                                        }" placeholder="选择到达时间" style="width: 100%;">
                                    </el-time-picker>

                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </template>

                <template v-if="add_data.travelWay == 2">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="出发站点" prop="splace" :rules="[
                                { required: false, message: '出发站点不能为空' },
                            ]">
                                <el-input v-model="add_data.splace" placeholder="请输入出发站点 eg：成都东站" maxlength="20"
                                    clearable style="width: 100%;">
                                </el-input>
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="到达站点" prop="eplace" :rules="[
                                { required: false, message: '到达站点不能为空' },
                            ]">
                                <el-input v-model="add_data.eplace" placeholder="请输入到达站点 eg：成都西站" maxlength="20"
                                    clearable style="width: 100%;">
                                </el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="出发时间" prop="stime" :rules="[
                                { required: false, message: '出发时间不能为空' },
                            ]">
                                <el-time-picker format="HH:mm" value-format="HH:mm" v-model="add_data.stime"
                                    :picker-options="{
                                        selectableRange: '00:00:00 - 23:59:59'
                                    }" placeholder="选择出发时间" style="width: 100%;">
                                </el-time-picker>
                            </el-form-item>
                        </el-col>

                        <el-col :span="12">
                            <el-form-item label="到达时间" prop="etime" :rules="[
                                { required: false, message: '到达时间不能为空' },
                            ]">
                                <el-time-picker format="HH:mm" value-format="HH:mm" v-model="add_data.etime"
                                    :picker-options="{
                                        selectableRange: '00:00:00 - 23:59:59'
                                    }" placeholder="选择到达时间" style="width: 100%;">
                                </el-time-picker>

                            </el-form-item>
                        </el-col>
                    </el-row>
                    <div v-for="item, index in add_data.wayPlaces" :key="index">

                        <el-divider v-if="index != 0">
                            <el-button @click="and_del_btn(index)" type="danger" icon="star-filled">删除</el-button>
                        </el-divider>
                        <el-row>
                            <el-col :span="8">
                                <el-form-item label="途径站点" prop="wayPlace" :rules="[
                                    { required: false, message: '途径站点不能为空' },
                                ]">
                                    <el-input v-model="item.wayPlace" placeholder="请输入途径站点" maxlength="20" clearable
                                        style="width: 100%;">
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="到达时间" prop="wayStime" :rules="[
                                    { required: false, message: '到达途径地时间不能为空' },
                                ]">
                                    <el-time-picker format="HH:mm" value-format="HH:mm" v-model="item.wayStime"
                                        :picker-options="{
                                            selectableRange: '00:00:00 - 23:59:59'
                                        }" placeholder="到达途径地时间" style="width: 160px;">
                                    </el-time-picker>

                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="出发时间" prop="wayEtime" :rules="[
                                    { required: false, message: '从途径地出发时间不能为空' },
                                ]"> <el-time-picker format="HH:mm" value-format="HH:mm" v-model="item.wayEtime"
                                        :picker-options="{
                                            selectableRange: '00:00:00 - 23:59:59'
                                        }" placeholder="从途径地出发时间" style="width: 160px;">
                                    </el-time-picker>

                                </el-form-item>
                            </el-col>


                        </el-row>

                    </div>
                </template>
            </el-form>
            <div style="display: flex;margin-left:25vw;margin-top:5px">
                <el-button @click="and_btn" type="warning">继续添加航班车次信息</el-button>
                <el-button @click="ok_btn" type="primary">确认提交</el-button>
            </div>
        </el-dialog>
    </div>
</template>
`
<script setup>
import Sortable from 'sortablejs';
import { ref, reactive, onMounted, computed, watch } from 'vue'
import {
    addFlightTrainInfo, delFlightTrainInfo, getFlightTrainInfoPages, modifyFlightTrainInfo,
    adupPrivateSet, getPrivateSetList, adUpFlightTrainInfo
} from '@/api/customer_list.js'
import { ElMessage, ElLoading, ElMessageBox } from 'element-plus'
import CircularJSON from 'circular-json'
onMounted(async () => {

    getPrivateSetList({
        find: '航班车次列表',
        page: {
            pageNum: 1,
            pageSize: 999,
        },
    }).then(res => {
        if (res.data.list[0]) {
            table_data_list_new.value = JSON.parse(res.data.list[res.data.list.length - 1].dat)
        } else {
            table_data_list_new.value = table_data_list
        }
    })


    Sortable.create(sortableContainer.value, {
        draggable: '.drag_it',
        ghostClass: 'sortable-ghost',
        onEnd: evt => {
            const targetRow = table_data_list_new.value.splice(evt.oldIndex, 1)[0];
            table_data_list_new.value.splice(evt.newIndex, 0, targetRow);

            // 重新赋值给列数组
            // let cols = that.U.scopy(that.fields);
            // let list = cols.filter(it => { return it.show; });
            // that.$emit('saveSet', {dgName: that.dgName, cols: list});
        }
    })
    await list_api()
})


//#region 表格数据处理
const table_data_list = reactive([
    { label: '班次/车次号', field: 'flightTrainNum', width: 120, off: true },
    { label: '班次/车次信息', field: 'numInfo', width: '', off: true },
    { label: '添加时间', field: 'addTime', width: 165, off: true },
])

const table_data_list_new = ref([])
const icon_off = ref(false)
// 创建排序容器的引用
const sortableContainer = ref('')

const icon_btn = () => {
    icon_off.value = !icon_off.value
    console.log(sortableContainer.value)

}
const resetTableSet = () => {
    console.log(table_data_list)
    table_data_list_new.value = JSON.parse(JSON.stringify(table_data_list))
    console.log(table_data_list)
    console.log(table_data_list_new.value)
}
const saveTableSet = () => {
    adupPrivateSet({
        dat: JSON.stringify(table_data_list_new.value),
        tbName: '航班车次列表',
        tbNum: "flightTrainInfo",
    }).then(res => {
        if (res.code == 1) {
            return ElMessage({
                message: res.msg,
                type: 'success',
            })
        } else {
            return ElMessage({
                message: res.msg,
                type: 'warning',
            })
        }
    })
    icon_off.value = false
}

const checkbox_btn = (e, c) => {
    for (let i = 0; i < table_data_list_new.value.length; i++) {
        if (table_data_list_new.value[i].label == c.target._value) {
            table_data_list_new.value[i].off == e

        }

    }

}

const sortedItems = computed(() => {
    return [...table_data_list_new.value].sort((a, b) => a.id - b.id);
})
//#endregion



//#region 分页列表
const list_data = ref([])
const find_data = reactive({
    page: {
        pageNum: 1,
        pageSize: 20,
    },
    find: '',
})
const total = ref(0)

// 分页器一夜显示多少数据页面
const size_change_btn = () => {
    find_data.page.pageNum = 1
    list_api()
}

// 分页器跳转页面
const current_change_btn = () => {
    list_api()
}

const list_api = () => {

    getFlightTrainInfoPages(find_data).then(res => {

        let list2 = res.data.list
        for (let i = 0; i < list2.length; i++) {
            list2[i].numInfo = JSON.parse(list2[i].numInfo)

        }
        list_data.value = list2

        console.log(list_data.value)
        total.value = res.data.total
    })
}
//#endregion

//#region 添加
const and_btn = () => {
    let data = {
        scity: '',
        splace: '',
        sterminal: '',
        stime: '',
        ecity: '',
        eplace: '',
        eterminal: '',
        etime: '',
    }
    let data2 = {
        wayPlace: '',
        wayStime: '',
        wayEtime: '',
    }
    if (add_data.travelWay == 1) {
        add_data.flightInfo.push(data)
    } else {
        add_data.wayPlaces.push(data2)
    }


}

const and_del_btn = (e) => {

    if (add_data.travelWay == 1) {
        add_data.flightInfo.splice(e, 1)
    } else {
        add_data.wayPlaces.splice(e, 1)
    }


}

const terminal_off = (e) => {
    let data = true
    if (e.includes('天府') || e.includes('双流')) {
        data = false
    } else {
        data = true
    }
    return data
}


const add_off = ref(false)

const title = ref('添加航班车次列表')
const add_data = reactive({
    // 修改对象id eg:1
    id: null,
    // 出行方式：1飞机 2火车
    travelWay: '1',
    // 班次号
    flightTrainNum: null,
    // 航班信息，航班必传数组
    flightInfo: [
        {
            scity: '',
            splace: '',
            sterminal: '',
            stime: '',
            ecity: '',
            eplace: '',
            eterminal: '',
            etime: '',
        }
    ],
    // 火车必传参数，到达站点 eg:成都东站
    eplace: '',
    etime: '',
    splace: '',
    stime: '',
    wayPlaces: [
        {
            wayPlace: '',
            wayStime: '',
            wayEtime: '',
        }
    ],


})

//#region 航班站点下拉框 t1



//#endregion

const add_btn = () => {
    title.value = '添加航班车次列表'
    add_data.id = ''
    add_data.travelWay = '1'
    add_data.flightTrainNum = ''
    add_data.flightInfo = [
        {
            scity: '',
            splace: '',
            sterminal: '',
            stime: '',
            ecity: '',
            eplace: '',
            eterminal: '',
            etime: '',
        }
    ]
    add_data.eplace = ''
    add_data.etime = ''
    add_data.splace = ''
    add_data.stime = ''
    add_data.wayPlaces = [
        {
            wayPlace: '',
            wayStime: '',
            wayEtime: '',
        }
    ]

    add_off.value = true

}


//#endregion

//#region 修改
const up_btn = () => {
    if (table_list.value.length != 1) {
        return ElMessage({
            message: '请选择一条数据！',
            type: 'warning',
        })
    }

    title.value = '修改航班车次列表'

    add_data.id = ''
    add_data.travelWay = '1'
    add_data.flightTrainNum = ''
    add_data.flightInfo = [
        {
            scity: '',
            splace: '',
            sterminal: '',
            stime: '',
            ecity: '',
            eplace: '',
            eterminal: '',
            etime: '',
        }
    ]
    add_data.eplace = ''
    add_data.etime = ''
    add_data.splace = ''
    add_data.stime = ''
    add_data.wayPlaces = [
        {
            wayPlace: '',
            wayStime: '',
            wayEtime: '',
        }
    ]


    // add_data.id = table_list.value[0].id
    // add_data.customers = table_list.value[0].customers

    // 处理数据
    let r = table_list.value[0]
    // let o = {};
    // 修改对象id eg:1
    add_data.id = r.id
    // 出行方式：1飞机 2火车
    add_data.travelWay = r.numInfo.travelWay + '';
    // 班次号
    add_data.flightTrainNum = r.flightTrainNum;

    if (add_data.travelWay == 1) {


        let data_list = []
        for (let i = 0; i < r.numInfo.list.length; i++) {
            let data = {
                scity: r.numInfo.list[i].depCity,
                splace: r.numInfo.list[i].depPort,
                sterminal: r.numInfo.list[i].depTerminal.length == 1 ? 'T' + r.numInfo.list[i].depTerminal : r.numInfo.list[i].depTerminal,
                stime: r.numInfo.list[i].depScheduled?.split(' ')[1] || null,
                ecity: r.numInfo.list[i].arrCity,
                eplace: r.numInfo.list[i].arrPort,
                eterminal: r.numInfo.list[i].arrTerminal.length == 1 ? 'T' + r.numInfo.list[i].arrTerminal : r.numInfo.list[i].arrTerminal,
                etime: r.numInfo.list[i].arrScheduled?.split(' ')[1] || null,
            }
            data_list.push(data)

        }
        add_data.flightInfo = data_list

    } else {


        add_data.eplace = r.numInfo.list[r.numInfo.list.length - 1].station;
        add_data.etime = r.numInfo.list[r.numInfo.list.length - 1].arrivaltime;
        add_data.splace = r.numInfo.list[0].station;
        add_data.stime = r.numInfo.list[0].departuretime;

        let data_list = []
        let numInfo_list = r.numInfo.list.slice(1, r.numInfo.list.length - 1);

        for (let i = 0; i < numInfo_list.length; i++) {
            let data = {
                wayPlace: numInfo_list[i].station,
                wayStime: numInfo_list[i].departuretime,
                wayEtime: numInfo_list[i].arrivaltime,
            }
            data_list.push(data)

        }
        add_data.wayPlaces = data_list



    }



    add_off.value = true
}
//#endregion


//#region 表格选择
const table_list = ref([])
const selection_change_btn = (e) => {
    table_list.value = e
    console.log(e)
}
//#endregion

// 提交
const ok_btn = () => {

    if (add_data.travelWay == 1) {
        for (let i = 0; i < add_data.flightInfo.length; i++) {
            if (!add_data.flightInfo[i].scity) {
                add_data.flightInfo.splice(i, 1)
            }
        }
    } else {

        for (let i = 0; i < add_data.wayPlaces.length; i++) {
            if (add_data.wayPlaces[i].wayPlace == '') {
                add_data.wayPlaces.splice(i, 1)
            }
        }
        if (add_data.wayPlaces[0]) {
            if (!add_data.wayPlaces[0].wayPlace) {
                add_data.wayPlaces = null
            }
        } else {
            add_data.wayPlaces = null
        }


    }


    if (title.value == '添加航班车次列表') {



        adUpFlightTrainInfo(add_data).then(res => {
            if (res.code == 1) {
                list_api()
                add_off.value = false
                return ElMessage({
                    message: res.msg,
                    type: 'success',
                })
            } else {
                return ElMessage({
                    message: res.msg,
                    type: 'warning',
                })
            }
        })
    } else {


        adUpFlightTrainInfo(add_data).then(res => {
            if (res.code == 1) {
                list_api()
                add_off.value = false
                return ElMessage({
                    message: res.msg,
                    type: 'success',
                })
            } else {
                return ElMessage({
                    message: res.msg,
                    type: 'warning',
                })
            }
        })
    }
}


//#region 删除
const del_btn = () => {
    if (table_list.value.length != 1) {
        return ElMessage({
            message: '请选择一条数据！',
            type: 'warning',
        })
    }

    ElMessageBox.confirm(
        '是否确认删除客户?',
        {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning',
            distinguishCancelAndClose: 'true',
        }
    )
        .then(() => {
            delFlightTrainInfo({
                ids: [table_list.value[0].id]
            }).then(res => {
                if (res.code == 1) {
                    list_api()
                    return ElMessage({
                        message: res.msg,
                        type: 'success',
                    })
                } else {
                    return ElMessage({
                        message: res.msg,
                        type: 'warning',
                    })
                }
            })
        })
        .catch((e) => {
            if (e == 'cancel') {
                ElMessage({
                    type: 'warning',
                    message: '取消删除成功',
                })
            }

        })

}
//#endregion

//#region 搜索
const search_btn = () => {
    list_api()
}
//#endregion
</script>

<style scoped lang='scss'></style>
<style>
.col-items::-webkit-scrollbar {
    width: 5px !important;
}

.col-items>label {
    margin-left: 0px !important;
    margin-top: 5px;
    width: 100%;
}

.el-table .el-table__cell {
    padding: 0px !important;
}
</style>
